<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Astrology Tools | 星盘</title>
    <style>
        /* 基础样式重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
            tap-highlight-color: transparent;
            outline: none;
        }

        /* 为可点击元素添加特定样式 */
        button,
        [class$="-btn"],
        a,
        [role="button"] {
            -webkit-tap-highlight-color: transparent;
            tap-highlight-color: transparent;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            outline: none;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #0a0e17 0%, #121827 100%);
            color: #ffffff;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 10px;
            overflow-x: hidden;
            overflow-y: auto;
        }

        /* 隐藏所有元素的滚动条但允许滚动 */
        * {
            scrollbar-width: none; /* Firefox */
        }

        *::-webkit-scrollbar {
            display: none; /* Chrome, Safari, Edge */
        }

        html {
            -ms-overflow-style: none; /* IE and Edge */
        }

        /* 页面标题 */
        header {
            text-align: center;
            margin-bottom: 25px;
            z-index: 10;
            padding: 15px 0;
        }

        h1 {
            font-size: 2.5rem;
            font-weight: 700;
            margin: 0;
            background: linear-gradient(90deg, #3b82f6, #60a5fa, #93c5fd, #bfdbfe, #dbeafe);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            background-size: 400% 400%;
            animation: gradientFlow 15s ease infinite;
            text-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
            letter-spacing: 1px;
        }

        @keyframes gradientFlow {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        /* 主内容容器 */
        .main-content-container {
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        /* 标签页样式 */
        .tabs-container {
            width: 100%;
            margin-bottom: 20px;
            background: rgba(17, 24, 39, 0.9);
            backdrop-filter: blur(12px);
            border-radius: 16px;
            border: 1px solid rgba(59, 130, 246, 0.2);
            overflow: hidden;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        }

        .tabs {
            display: flex;
            border-bottom: 2px solid rgba(59, 130, 246, 0.2);
            overflow-x: auto;
            overflow-y: hidden;
            scroll-behavior: smooth;
            -webkit-overflow-scrolling: touch;
            background: rgba(15, 23, 42, 0.7);
            /* 防止内容换行 */
            flex-wrap: nowrap;
            /* 允许触摸滑动 */
            touch-action: pan-x;
            -ms-touch-action: pan-x;
            /* 固定容器宽度以启用滚动 */
            width: 100%;
            /* 移除可能阻止滚动的属性 */
            max-width: 100%;
            /* 确保子元素不会被压缩 */
            align-items: stretch;
        }

        /* 隐藏滚动条但保持功能 */
        .tabs::-webkit-scrollbar {
            display: none;
        }

        .tabs {
            -ms-overflow-style: none;
            scrollbar-width: none;
        }

        .tab {
            background: transparent;
            border: none;
            color: #94a3b8;
            font-size: 1.1rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            text-align: center;
            padding: 18px 30px;
            white-space: nowrap;
            position: relative;
            overflow: visible;
            /* 确保按钮不会被压缩 */
            flex-shrink: 0;
            /* 确保文本完整显示 */
            min-width: max-content;
        }

        .tab::before {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 3px;
            background: #3b82f6;
            transition: width 0.3s ease;
        }

        .tab:hover {
            background: rgba(59, 130, 246, 0.1);
            color: #ffffff;
        }

        .tab.active {
            color: #ffffff;
            background: rgba(59, 130, 246, 0.15);
        }

        .tab.active::before {
            width: 100%;
        }

        /* 内容区域 - 不限制宽度 */
        .tab-content {
            display: none;
            padding: 0;
            min-height: 0;
        }

        .tab-content.active {
            display: block;
            width: 100%;
        }

        /* iframe样式 */
        .tab-iframe {
            width: 100%;
            height: calc(100vh - 200px);
            border: none;
            background: transparent;
            min-width: 100%;
            box-sizing: border-box;
            transition: height 0.5s ease;
        }

        /* 星星背景 */
        .stars {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            pointer-events: none;
        }

        .star {
            position: absolute;
            background-color: white;
            border-radius: 50%;
            box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
        }

        @keyframes twinkle {
            0% { opacity: 0.3; transform: scale(0.8); }
            50% { opacity: 1; transform: scale(1.2); }
            100% { opacity: 0.3; transform: scale(0.8); }
        }

        /* 响应式调整 */
        @media (max-width: 768px) {
            body {
                padding: 0px;
            }

            h1 {
                font-size: 2rem;
                letter-spacing: 0.5px;
            }

            .tab {
                padding: 15px 22px;
                font-size: 1rem;
            }

            .tab-iframe {
                height: calc(100vh - 180px);
            }
        }

        @media (max-width: 480px) {
            h1 {
                font-size: 1.8rem;
            }

            .tab {
                padding: 12px 18px;
                font-size: 0.95rem;
            }

            .tabs-container {
                border-radius: 12px;
            }
        }
    </style>
</head>
<body>
<!-- 星星背景 (将通过JS动态生成) -->
<div class="stars"></div>

<header>
    <h1>星盘</h1>
</header>

<!-- 主内容容器 - 统一控制宽度 -->
<div class="main-content-container">
    <!-- 标签页容器 -->
    <div class="tabs-container">
        <div class="tabs">
            <button class="tab active" data-tab="zodiac">星座罗盘</button>
            <button class="tab" data-tab="natal">本命星盘</button>
            <button class="tab" data-tab="transit">行运盘</button>
            <button class="tab" data-tab="vedic">吠陀占星图</button>
            <button class="tab" data-tab="solar">太阳返照盘</button>
            <button class="tab" data-tab="lunar">月亮返照盘</button>
        </div>
    </div>

    <!-- 内容区域 -->
    <div class="tab-content active" id="zodiac">
        <iframe class="tab-iframe" src="ZodiacCompass.html"></iframe>
    </div>
    <div class="tab-content" id="natal">
        <iframe class="tab-iframe" src="NatalChart.html"></iframe>
    </div>
    <div class="tab-content" id="transit">
        <iframe class="tab-iframe" src="TransitChart.html"></iframe>
    </div>
    <div class="tab-content" id="vedic">
        <iframe class="tab-iframe" src="VedicChart.html"></iframe>
    </div>
    <div class="tab-content" id="solar">
        <iframe class="tab-iframe" src="SolarReturnChart.html"></iframe>
    </div>
    <div class="tab-content" id="lunar">
        <iframe class="tab-iframe" src="LunarReturnChart.html"></iframe>
    </div>
</div>

<script>
    // 创建星星背景
    function createStars() {
        const starsContainer = document.querySelector('.stars');
        const starCount = 150; // 星星数量

        for (let i = 0; i < starCount; i++) {
            const star = document.createElement('div');
            star.classList.add('star');

            // 随机位置
            const x = Math.random() * 100;
            const y = Math.random() * 100;

            // 随机大小
            const size = Math.random() * 2 + 0.5;

            // 随机动画延迟
            const delay = Math.random() * 2;

            // 设置样式
            star.style.left = `${x}%`;
            star.style.top = `${y}%`;
            star.style.width = `${size}px`;
            star.style.height = `${size}px`;
            star.style.animationDelay = `${delay}s`;

            starsContainer.appendChild(star);
        }
    }

    // 标签页切换功能
    function setupTabs() {
        const tabs = document.querySelectorAll('.tab');
        const tabContents = document.querySelectorAll('.tab-content');

        tabs.forEach(tab => {
            tab.addEventListener('click', () => {
                // 获取标签页ID
                const tabId = tab.getAttribute('data-tab');

                // 移除所有活动状态
                tabs.forEach(t => t.classList.remove('active'));
                tabContents.forEach(content => content.classList.remove('active'));

                // 添加当前活动状态
                tab.classList.add('active');
                document.getElementById(tabId).classList.add('active');
            });
        });
    }

    // 检测页面是否在iframe中加载，并添加相应的class和样式
    function setupIframeClass() {
        const iframes = document.querySelectorAll('.tab-iframe');

        iframes.forEach(iframe => {
            iframe.onload = function() {
                try {
                    // 获取iframe中的文档对象
                    const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
                    // 添加in-iframe类
                    iframeDoc.body.classList.add('in-iframe');

                    // 动态调整iframe高度和宽度以适应内容
                    function resizeIframe() {
                        // 调整高度
                        const newHeight = iframeDoc.body.scrollHeight + 50;
                        iframe.style.height = newHeight + 'px';

                        // 确保宽度充满容器
                        iframe.style.width = '100%';
                        iframe.style.minWidth = '100%';
                    }

                    // 初始调整
                    resizeIframe();

                    // 监听子页面内容变化
                    const observer = new MutationObserver(resizeIframe);
                    observer.observe(iframeDoc.body, {
                        childList: true,
                        subtree: true,
                        attributes: true,
                        characterData: true
                    });

                    // 监听窗口大小变化
                    window.addEventListener('resize', resizeIframe);
                } catch (e) {
                    // 可能存在跨域安全限制，忽略错误
                    console.log('无法访问iframe内容，可能存在跨域限制');
                }
            };
        });
    }

    // 初始化页面
    function init() {
        createStars();
        setupTabs();
        setupIframeClass();
    }

    // 页面加载完成后初始化
    window.addEventListener('load', init);
</script>
</body>
</html>